class Ass3Test{
	public static void main(String args[]) {
		int grade = 100;
//		grade = test1PartA(grade);
//		System.out.println("finished Test part 1 A, grade= "+ grade);
//		grade = test2PartA(grade);
//		System.out.println("finished Test part 2  A, grade= "+ grade);
//		grade = test3PartA(grade);
//		System.out.println("finished Test part 3 A, grade= "+ grade);
//		grade = test4PartA(grade);
//		System.out.println("finished Test part 4 A, grade= "+ grade);
//		grade = test5PartA(grade);
//		System.out.println("finished Test part 5 A, grade= "+ grade);
//		grade = test6PartA(grade);
//		System.out.println("finished Test part 6 A, grade= "+ grade);
		
		grade = test1(grade);
		System.out.println("finished Test1, grade= "+ grade);
		grade = test2(grade);
		System.out.println("finished Test2, grade= "+ grade);
		grade = test3(grade);
		System.out.println("finished Test3, grade= "+ grade);
		grade = test4(grade);
		System.out.println("finished Test4, grade= "+ grade);
		grade = test5(grade);
		System.out.println("finished Test5, grade= "+ grade);
		grade = test6(grade);
		System.out.println("finished Test6, grade= "+ grade);
		grade = test7(grade);
		System.out.println("finished Test7, grade= "+ grade);
		System.out.println("final grade: "+ grade);
	}

	public static int test1(int grade) {
		int cRows = 2, cCols = 2;
		int[][] aiKnapsack = null;
		int[][] aiRectangles = new int[4][2];
		String ans = "";
		String respAns1 = "12\n34\n";
		String respAns2 = "12\n34";
		String respAns3 ="14\n23";
		String respAns4 ="14\n23\n";
				
		aiRectangles[0][0] = 1;
		aiRectangles[0][1] = 1;
		aiRectangles[1][0] = 1;
		aiRectangles[1][1] = 1;
		aiRectangles[2][0] = 1;
		aiRectangles[2][1] = 1;
		aiRectangles[3][0] = 1;
		aiRectangles[3][1] = 1;
		
		aiKnapsack = Knapsack.insertIntoKnapsack( cRows, cCols, aiRectangles );
		if( aiKnapsack != null ){
			ans = Knapsack.getKnapsackString( aiKnapsack); 
			if (!(ans.equals(respAns1)|| ans.equals(respAns2)|| ans.equals(respAns3)|| ans.equals(respAns4))){
				System.out.println("Test1: you've got:\n" + ans + "instead of:\n" +respAns1);
				grade = grade - 7;
			}
		}
		else{
			System.out.println( "Test1:Could not insert rectangles into knapsack" );
			grade = grade - 7;
		}
		return grade;
		/*
		12
		34
		*/
	}

	public static int test2(int grade){
		int cRows = 2, cCols = 10;
		int[][] aiKnapsack = null;
		int[][] aiRectangles = new int[5][2];
		String ans = "";
		String respAns2 = "1122223400\n1122223555\n";
		String respAns1 = "1122223400\n1122223555";
		
				
		aiRectangles[0][0] = 2;
		aiRectangles[0][1] = 2;
		aiRectangles[1][0] = 2;
		aiRectangles[1][1] = 4;
		aiRectangles[2][0] = 2;
		aiRectangles[2][1] = 1;
		aiRectangles[3][0] = 1;
		aiRectangles[3][1] = 1;
		aiRectangles[4][0] = 1;
		aiRectangles[4][1] = 3;
		
		aiKnapsack = Knapsack.insertIntoKnapsack( cRows, cCols, aiRectangles );
		if( aiKnapsack != null ){
			ans = Knapsack.getKnapsackString( aiKnapsack); 
			if (!(ans.equals(respAns1)|| ans.equals(respAns2))){
				System.out.println("Test2: you've got:\n" + ans + "instead of:\n" +respAns1);
				grade = grade - 7;
			}
		}
		else{
			System.out.println( "Test2:Could not insert rectangles into knapsack" );
			grade = grade - 7;
		}
		/*
		1122223400
		1122223555
		*/
		return grade;
	}
	
	public static int test3(int grade){
		int cRows = 4, cCols = 4;
		int[][] aiKnapsack = null;
		int[][] aiRectangles = new int[5][2];
		String ans = "";
		String respAns1 = "2223\n4113\n4113\n4555";
		String respAns2 = "2223\n4113\n4113\n4555\n";
		String respAns3 ="2444\n2115\n2115\n3335\n";
		String respAns4 ="2444\n2115\n2115\n3335";
		String respAns6 ="2333\n2115\n2115\n4445\n";
		String respAns5 ="2333\n2115\n2115\n4445";
		
				
		aiRectangles[0][0] = 2;
		aiRectangles[0][1] = 2;
		aiRectangles[1][0] = 1;
		aiRectangles[1][1] = 3;
		aiRectangles[2][0] = 3;
		aiRectangles[2][1] = 1;
		aiRectangles[3][0] = 3;
		aiRectangles[3][1] = 1;
		aiRectangles[4][0] = 1;
		aiRectangles[4][1] = 3;
		
		aiKnapsack = Knapsack.insertIntoKnapsack( cRows, cCols, aiRectangles );
		if( aiKnapsack != null ){
			ans = Knapsack.getKnapsackString( aiKnapsack); 
			if (!(ans.equals(respAns1)|| ans.equals(respAns2)||ans.equals(respAns5)||ans.equals(respAns6)|| ans.equals(respAns3)|| ans.equals(respAns4))){
				System.out.println("Test3: you've got:\n" + ans + "instead of:\n" +respAns1);
				grade = grade - 7;
			}
		}
		else{
			System.out.println( "Test3:Could not insert rectangles into knapsack" );
			grade = grade - 7;
		}
		/*
		2223
		4113
		4113
		4555
		*/
		return grade;
	}
	public static int test4(int grade) {
		int cRows = 4, cCols = 8;
		int[][] aiKnapsack = null;
		int[][] aiRectangles = new int[7][2];
		String ans = "";
		String respAns2 = "11122223\n11145503\n66666000\n77777700";
		String respAns1 = "11122223\n11145503\n66666000\n77777700\n";
		
				
		aiRectangles[0][0] = 2;
		aiRectangles[0][1] = 3;
		aiRectangles[1][0] = 1;
		aiRectangles[1][1] = 4;
		aiRectangles[2][0] = 2;
		aiRectangles[2][1] = 1;
		aiRectangles[3][0] = 1;
		aiRectangles[3][1] = 1;
		aiRectangles[4][0] = 1;
		aiRectangles[4][1] = 2;
		aiRectangles[5][0] = 1;
		aiRectangles[5][1] = 5;
		aiRectangles[6][0] = 1;
		aiRectangles[6][1] = 6;
		
		aiKnapsack = Knapsack.insertIntoKnapsack( cRows, cCols, aiRectangles );
		if( aiKnapsack != null ){
			ans = Knapsack.getKnapsackString( aiKnapsack); 
			if (!(ans.equals(respAns1)|| ans.equals(respAns2))){
				System.out.println("Test4: you've got:\n" + ans + "instead of:\n" +respAns1);
				grade = grade - 7;
			}
		}
		else{
			System.out.println( "Test4: Could not insert rectangles into knapsack" );
			grade = grade - 7;
		}
		/*
		11122223
		11145503
		66666000
		77777700
		*/
		return grade;
	}
	public static int test5(int grade){
		int cRows = 7, cCols = 5;
		int[][] aiKnapsack = null;
		int[][] aiRectangles = new int[8][2];
		String ans = "";
		String respAns1 = "11134\n11130\n22220\n55088\n77788\n00088\n66666";
		String respAns2 = "11134\n11130\n22220\n55088\n77788\n00088\n66666\n";
		String respAns3 = "11134\n11130\n22220\n66666\n05588\n77788\n00088\n";
	    String respAns4 = "11134\n11130\n22220\n66666\n05588\n77788\n00088";
	    String respAns5 ="11134\n11130\n22220\n66666\n55088\n77788\n00088\n";
	    String respAns6 ="11134\n11130\n22220\n66666\n55088\n77788\n00088";
	    String respAns7 ="11006\n11706\n11706\n20706\n28886\n28885\n23345\n";
	    String respAns8= "11006\n11706\n11706\n20706\n28886\n28885\n23345";
	    String respAns9="11233\n11245\n11265\n00267\n88867\n88867\n00060";
	    String respAns10="11233\n11245\n11265\n00267\n88867\n88867\n00060\n";
		
				
		aiRectangles[0][0] = 2;
		aiRectangles[0][1] = 3;
		aiRectangles[1][0] = 1;
		aiRectangles[1][1] = 4;
		aiRectangles[2][0] = 2;
		aiRectangles[2][1] = 1;
		aiRectangles[3][0] = 1;
		aiRectangles[3][1] = 1;
		aiRectangles[4][0] = 1;
		aiRectangles[4][1] = 2;
		aiRectangles[5][0] = 1;
		aiRectangles[5][1] = 5;
		aiRectangles[6][0] = 1;
		aiRectangles[6][1] = 3;
		aiRectangles[7][0] = 3;
		aiRectangles[7][1] = 2;
		
		aiKnapsack = Knapsack.insertIntoKnapsack( cRows, cCols, aiRectangles );
		if( aiKnapsack != null ){
			ans = Knapsack.getKnapsackString( aiKnapsack); 
			if (!(ans.equals(respAns1)||ans.equals(respAns10)||ans.equals(respAns9) ||ans.equals(respAns8)|| ans.equals(respAns7)|| ans.equals(respAns2)||ans.equals(respAns5)||ans.equals(respAns6)||ans.equals(respAns3)|| ans.equals(respAns4))){
				System.out.println("Test5: you've got:\n" + ans + "instead of:\n" +respAns1);
				grade = grade - 7;
			}
		}
		else{
			System.out.println( "Test5: Could not insert rectangles into knapsack" );
			grade = grade - 7;
		}
		/*
		11134
		11130
		22220
		55088
		77788
		00088
		66666
		 
		 */
		return grade;
	}
	
	public static int test6(int grade){
		int cRows = 10, cCols = 5;
		int[][] aiKnapsack = null;
		int[][] aiRectangles = new int[3][2];
		String ans = "";
		String respAns2 = "12222\n12222\n12222\n12222\n13333\n13333\n13333\n13333\n10000\n10000\n";
		String respAns1 = "12222\n12222\n12222\n12222\n13333\n13333\n13333\n13333\n10000\n10000";
				
		aiRectangles[0][0] = 10;
		aiRectangles[0][1] = 1;
		aiRectangles[1][0] = 4;
		aiRectangles[1][1] = 4;
		aiRectangles[2][0] = 4;
		aiRectangles[2][1] = 4;
		
		
		aiKnapsack = Knapsack.insertIntoKnapsack( cRows, cCols, aiRectangles );
		if( aiKnapsack != null ){
			ans = Knapsack.getKnapsackString( aiKnapsack); 
			if (!(ans.equals(respAns1)|| ans.equals(respAns2))){
				System.out.println("Test6: you've got:\n" + ans + "instead of:\n" +respAns1);
				grade = grade - 7;
			}
		}
		else{
			System.out.println( "Test6:Could not insert rectangles into knapsack" );
			grade = grade - 7;
		}
		return grade;
	}

	public static int test7(int grade){
		int cRows = 4, cCols = 4;
		int[][] aiKnapsack = null;
		int[][] aiRectangles = new int[5][2];
		String ans = "";
		
		
				
		aiRectangles[0][0] = 10;
		aiRectangles[0][1] = 10;
		aiRectangles[1][0] = 10;
		aiRectangles[1][1] = 10;
		aiRectangles[2][0] = 10;
		aiRectangles[2][1] = 10;
		aiRectangles[3][0] = 10;
		aiRectangles[3][1] = 10;
		aiRectangles[4][0] = 10;
		aiRectangles[4][1] = 10;
		
		aiKnapsack = Knapsack.insertIntoKnapsack( cRows, cCols, aiRectangles );
		if( aiKnapsack != null ){
				ans = Knapsack.getKnapsackString( aiKnapsack); 
				System.out.println("Test7: you've got:\n" + ans + "instead of No solution!");
				grade = grade - 7;
		}
		else{
			//System.out.println( "Test7: Could not insert rectangles into knapsack" );
		}
		return grade;
	}
	
}